package logic

import (
	"context"
	"ewaimai/waimairpc/models"

	"ewaimai/waimairpc/internal/svc"
	"ewaimai/waimairpc/waimairpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type PinglunAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPinglunAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PinglunAddLogic {
	return &PinglunAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *PinglunAddLogic) PinglunAdd(in *waimairpc.PinglunAddRequest) (*waimairpc.PinglunAddResponse, error) {
	// todo: add your logic here and delete this line
	var p models.OrderPinglun
	p.Context = in.Context
	p.Start = float64(in.Start)
	p.Image = in.Image
	p.Shoppeople = in.Shoppeople
	p.Qishou = in.Qishou
	p.Status = 1
	if err := p.CreateOrderPinglun(); err != nil {
		logx.Errorf("评价失败")
	}
	return &waimairpc.PinglunAddResponse{
		Id: int64(p.ID),
	}, nil
}
